package jp.co.toshiba.ffsa.action.csde;

import javax.annotation.Resource;

import jp.co.toshiba.ffsa.action.common.CommonAction;
import jp.co.toshiba.ffsa.form.csde.Csde602Form;

import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;

public class Csde602Action extends CommonAction{
    /** 画面ID */
    public String screenID = "CSDE602";

    /** アクションフォーム */
    @ActionForm
    @Resource
    protected Csde602Form csde602Form;

    /**
     * 初期処理
     * @return 画面遷移先
     */
    @Execute(validator = false)
    public String index() throws Exception{
        // ログイン済判定する
        if(this.judgeLogin(csde602Form.getSessionId())){
            try{
                // リファラ判定
                if(this.judgeRefferer()){
                    return "/csde/csde602.jsp";
                }else{
                    return this.topTransition;
                }
            }catch(Exception e){
                this.errorLogWriter(e, "index", this.screenID);
                throw e;
            }
        }else{
            return this.topTransition;
        }
    }

    @Execute(validator = true,input="/csde/csde602/error")
    public String back() throws Exception {
        // ログイン済判定する
        if(this.judgeLogin(csde602Form.getSessionId())){
            try{
                // リファラ判定
                if(this.judgeRefferer()){
                    return "/csde/csde301";
                }else{
                    return this.topTransition;
                }
            }catch(Exception e){
                this.errorLogWriter(e, "back", this.screenID);
                throw e;
            }
        }else{
            return this.topTransition;
        }
    }

    /**
     * バリデーションエラー処理
     * @return 遷移先
     * @throws Exception
     */
    @Execute(validator = false)
    public String error() throws Exception {
        // ログイン済判定する
        if(this.judgeLogin(csde602Form.getSessionId())){
            try {
                // リファラ判定
                if(this.judgeRefferer()){
                    // セッションタイムアウト判定
                    if(this.judgeSession()){
                        return index();
                    }else{
                        return this.topTransition;
                    }
                }else{
                    return this.topTransition;
                }
            }catch(Exception e) {
                this.errorLogWriter(e, "back", this.screenID);
                throw e;
            }
        }else{
            return this.topTransition;
        }
    }

}
